package org.jprogger.myworld.api.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jprogger.myworld.api.ApiServiceInvocationException;
import org.jprogger.myworld.api.app.AppContext;
import org.jprogger.myworld.api.model.Audio;
import org.jprogger.myworld.api.response.ApiResponse;
import org.jprogger.myworld.api.response.handler.AddAudioApiResponseHandler;
import org.jprogger.myworld.api.response.handler.GetListAudioApiResponseHandler;

/**
 * 
 * @author jprogger
 * 
 */
public class AudioService extends BaseApiService {
	
	public AudioService(AppContext context) {
		super(context);
	}

	public ApiResponse<Integer> addAudio(int audioId) throws ApiServiceInvocationException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("mid", audioId);
		params.put("method", "audios.linkAudio");
		return apiCall(params, new AddAudioApiResponseHandler());
	}

	public ApiResponse<List<Audio>> getAudios(int[] audioIds) throws ApiServiceInvocationException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("mids", audioIds);
		params.put("uid", context.getAppParams().getViewerId());
		params.put("method", "audios.get");
		return apiCall(params, new GetListAudioApiResponseHandler());
	}
}
